<div class="blazorise-codeblock">
<div class="html"><pre>
<span class="htmlTagDelimiter">&lt;</span><span class="htmlElementName">TreeView</span> <span class="htmlAttributeName">Nodes</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="htmlAttributeValue">Items</span><span class="quot">&quot;</span>
          <span class="htmlAttributeName">GetChildNodes</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="htmlAttributeValue"><span class="atSign">&#64;</span>(item =&gt; item.Children)</span><span class="quot">&quot;</span>
          <span class="htmlAttributeName">HasChildNodes</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="htmlAttributeValue"><span class="atSign">&#64;</span>(item =&gt; item.Children?.Any() == true)</span><span class="quot">&quot;</span>
          <span class="htmlAttributeName"><span class="atSign">&#64;</span>bind-SelectedNode</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="htmlAttributeValue">selectedNode</span><span class="quot">&quot;</span>
          <span class="htmlAttributeName"><span class="atSign">&#64;</span>bind-ExpandedNodes</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="htmlAttributeValue">expandedNodes</span><span class="quot">&quot;</span><span class="htmlTagDelimiter">&gt;</span>
    <span class="htmlTagDelimiter">&lt;</span><span class="htmlElementName">NodeContent</span><span class="htmlTagDelimiter">&gt;</span>
        <span class="htmlTagDelimiter">&lt;</span><span class="htmlElementName">Icon</span> <span class="htmlAttributeName">Name</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="enum">IconName</span><span class="enumValue">.Folder</span><span class="quot">&quot;</span> <span class="htmlTagDelimiter">/&gt;</span>
        <span class="atSign">&#64;</span>context.Text
    <span class="htmlTagDelimiter">&lt;/</span><span class="htmlElementName">NodeContent</span><span class="htmlTagDelimiter">&gt;</span>
<span class="htmlTagDelimiter">&lt;/</span><span class="htmlElementName">TreeView</span><span class="htmlTagDelimiter">&gt;</span>
</pre></div>
<div class="csharp"><pre>
<span class="atSign">&#64;</span>code{
    <span class="keyword">public</span> <span class="keyword">class</span> Item
    {
        <span class="keyword">public</span> <span class="keyword">string</span> Text { <span class="keyword">get</span>; <span class="keyword">set</span>; }
        <span class="keyword">public</span> IEnumerable&lt;Item&gt; Children { <span class="keyword">get</span>; <span class="keyword">set</span>; }
    }

    IEnumerable&lt;Item&gt; Items = <span class="keyword">new</span>[]
    {
        <span class="keyword">new</span> Item { Text = <span class="string">&quot;Item 1&quot;</span> },
        <span class="keyword">new</span> Item
        {
            Text = <span class="string">&quot;Item 2&quot;</span>,
            Children = <span class="keyword">new</span> []
            {
                <span class="keyword">new</span> Item { Text = <span class="string">&quot;Item 2.1&quot;</span> },
                <span class="keyword">new</span> Item
                {
                    Text = <span class="string">&quot;Item 2.2&quot;</span>,
                    Children = <span class="keyword">new</span> []
                    {
                        <span class="keyword">new</span> Item { Text = <span class="string">&quot;Item 2.2.1&quot;</span> },
                        <span class="keyword">new</span> Item { Text = <span class="string">&quot;Item 2.2.2&quot;</span> },
                        <span class="keyword">new</span> Item { Text = <span class="string">&quot;Item 2.2.3&quot;</span> },
                        <span class="keyword">new</span> Item { Text = <span class="string">&quot;Item 2.2.4&quot;</span> }
                    }
                },
                <span class="keyword">new</span> Item { Text = <span class="string">&quot;Item 2.3&quot;</span> },
                <span class="keyword">new</span> Item { Text = <span class="string">&quot;Item 2.4&quot;</span> }
            }
        },
        <span class="keyword">new</span> Item { Text = <span class="string">&quot;Item 3&quot;</span> },
    };

    IList&lt;Item&gt; expandedNodes = <span class="keyword">new</span> List&lt;Item&gt;();
    Item selectedNode;
}
</pre></div>
</div>
